package cn.aliang.cloud.order.controller;

import cn.aliang.cloud.service.entity.ResultMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: chendongliang
 * @Date: 2020/7/20 17:02
 */

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    RestTemplate restTemplate;

    //本地调用,去掉@LoadBlance
    //private static final String PAYMENT_URL = "http://localhost:9000";
    //加上@LoadBlance,通过Ribbon 实现负载
    private static final String PAYMENT_URL = "http://CLOUD-PAYMENT-SERVICE";

    @GetMapping("/pay/{id}")
    public ResultMessage<Void> pay(@PathVariable("id") String id ){
        return restTemplate.getForObject(PAYMENT_URL +"/payment/pay/"+id,ResultMessage.class);
    }

}
